<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.js"></script>
<script>
    const instance = axios.create({
        baseURL: 'http://139.186.146.184:8080'
    })
    // 尝试使用axios实例来请求学生列表
    // axios实例的请求使用方式和axios本身一样
    instance.get('/stu_list', {
        params: {
            currentPage: 1,
            pageSize: 10
        }
    }).then(res => {
        console.log(res)
    })
    //新增学生
    instance.post('/add_stu', {
        name: '张三',
        age: 10,
        score: 50,
        address: '金科'
    }).then(res => {
        console.log(res)
    })
    //修改学生
    instance.put('/update_stu', {
        id:8,
        name: '张三-新',
        age: 22,
        score: 100,
        address: '金科'
    }).then(res => {
        console.log(res)
    })
    //删除学生
    instance.delete('/del_stu', {
        params: {
            id: 8
        }
    }).then(res => {
        console.log(res)
    })



</script>